---
id: continue-as-new
title: Continue-As-New - PHP SDK
sidebar_label: Continue-As-New
slug: /develop/php/continue-as-new
toc_max_heading_level: 2
keywords:
  - continue-as-new
tags:
  - Workflows
  - continue-as-new
  - PHP SDK
  - Temporal SDKs
description: Learn how to use Continue-As-New to manage large Event Histories in Workflow Execution by creating a new execution with the same Workflow Id but a fresh Event History.
---

## How to Continue-As-New {#continue-as-new}

[Continue-As-New](/workflows#continue-as-new) enables a Workflow Execution to close successfully and create a new Workflow Execution in a single atomic operation if the number of Events in the Event History is becoming too large.
The Workflow Execution spawned from the use of Continue-As-New has the same Workflow Id, a new Run Id, and a fresh Event History and is passed all the appropriate parameters.

Workflows that need to rerun periodically could naively be implemented as a big **while** loop with a sleep where the entire logic of the Workflow is inside the body of the **while** loop.
The problem with this approach is that the history for that Workflow will keep growing to a point where it reaches the maximum size enforced by the service.

**ContinueAsNew** is the low level construct that enables implementing such Workflows without the risk of failures down the road.
The operation atomically completes the current execution and starts a new execution of the Workflow with the same **Workflow Id**.
The new execution will not carry over any history from the old execution.

To trigger this behavior, use `Workflow::continueAsNew` or `Workflow::newContinueAsNewStub` method:

```php
#[Workflow\WorkflowMethod]
public function periodic(string $name, int $value = 0)
{
    for ($i = 0; $i < 100; $i++) {
        // do something
        $value++;
    }

    // maintain $value counter between runs
    return Workflow::newContinueAsNewStub(self::class)->periodic($name, $value);
}
```

:::warning Using Continue-as-New and Updates

- Temporal _does not_ support Continue-as-New functionality within Update handlers.
- Complete all handlers _before_ using Continue-as-New.
- Use Continue-as-New from your main Workflow Definition method, just as you would complete or fail a Workflow Execution.

:::
